package com.isdepci.project.gasEmission.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.project.gasEmission.domain.FuelUse;
import com.isdepci.project.gasEmission.service.IFuelUseService;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.web.page.TableDataInfo;

/**
 * 现场燃料使用Controller
 *
 * @author isdepci
 * @date 2023-09-01
 */
@RestController
@RequestMapping("/fuelUse/fuelUse")
public class FuelUseController extends BaseController
{
    @Autowired
    private IFuelUseService fuelUseService;

    /**
     * 查询现场燃料使用列表
     */
    @PreAuthorize("@ss.hasPermi('fuelUse:fuelUse:list')")
    @GetMapping("/list")
    public TableDataInfo list(FuelUse fuelUse)
    {
        startPage();
        List<FuelUse> list = fuelUseService.selectFuelUseList(fuelUse);
        return getDataTable(list);
    }




    /**
     * 导出现场燃料使用列表
     */
    @PreAuthorize("@ss.hasPermi('fuelUse:fuelUse:export')")
    @Log(title = "现场燃料使用", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FuelUse fuelUse)
    {
        List<FuelUse> list = fuelUseService.selectFuelUseList(fuelUse);
        ExcelUtil<FuelUse> util = new ExcelUtil<FuelUse>(FuelUse.class);
        return util.exportExcel(list, "fuelUse");
    }

    /**
     * 获取现场燃料使用详细信息
     */
    @PreAuthorize("@ss.hasPermi('fuelUse:fuelUse:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fuelUseService.selectFuelUseById(id));
    }

    /**
     * 新增现场燃料使用
     */
    @PreAuthorize("@ss.hasPermi('fuelUse:fuelUse:add')")
    @Log(title = "现场燃料使用", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FuelUse fuelUse)
    {
        return toAjax(fuelUseService.insertFuelUse(fuelUse));
    }

    /**
     * 修改现场燃料使用
     */
    @PreAuthorize("@ss.hasPermi('fuelUse:fuelUse:edit')")
    @Log(title = "现场燃料使用", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FuelUse fuelUse)
    {
        return toAjax(fuelUseService.updateFuelUse(fuelUse));
    }

    /**
     * 删除现场燃料使用
     */
    @PreAuthorize("@ss.hasPermi('fuelUse:fuelUse:remove')")
    @Log(title = "现场燃料使用", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fuelUseService.deleteFuelUseByIds(ids));
    }
}
